//
//  SpecificationCell.m
//  LvXi_newVersion
//
//  Created by 王敏 on 16/8/25.
//  Copyright © 2016年 SJT. All rights reserved.
//

#import "SpecificationCell.h"

@interface SpecificationCell()
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *contentLabelHeight;

@end
@implementation SpecificationCell

-(void)awakeFromNib{
    [super awakeFromNib];
    self.backgroundColor = HexColor(@"#EEEEEE");
    self.contentView.backgroundColor = HexColor(@"#EEEEEE");
    self.cellHeight = 40;
    self.contentLabel.textColor = HexColor(@"#AAAAAA");
    self.contentLabel.font = [UIFont systemFontOfSize:14];
}

-(id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]){
        self.backgroundColor = HexColor(@"#EEEEEE");
        self.contentView.backgroundColor = HexColor(@"#EEEEEE");
        
        UILabel * titleLabel = [[UILabel alloc] init];
        titleLabel.font = [UIFont systemFontOfSize:14];
        titleLabel.textAlignment = NSTextAlignmentLeft;
        titleLabel.textColor = [UIColor blackColor];
        [self.contentView addSubview:titleLabel];
        self.titleLabel = titleLabel;
        
        UILabel * contentLabel = [[UILabel alloc] init];
        contentLabel.font = [UIFont systemFontOfSize:14];
        contentLabel.textAlignment = NSTextAlignmentLeft;
        contentLabel.textColor = HexColor(@"#AAAAAA");
        contentLabel.numberOfLines = 0;
        [self.contentView addSubview:contentLabel];
        self.contentLabel = contentLabel;

    }
    return self;
}


-(void)layoutSubviews{
    [super layoutSubviews];
    self.titleLabel.x = globalMargin;
    self.titleLabel.y = globalMargin;
    self.titleLabel.size = [self.titleLabel.text sizeInAre:MaxSize font:self.titleLabel.font];
    
    self.contentLabel.x = 150;
    self.contentLabel.y = globalMargin;
    self.contentLabel.size = [self.contentLabel.text sizeInAre:CGSizeMake(ScreenWidth - self.titleLabel.right - 3*globalMargin, MAXFLOAT) font:self.contentLabel.font];
    
    self.cellHeight = self.contentLabel.height + 2*globalMargin;
}

-(void)setTitle:(NSString *)title content:(NSString *)content{
    self.titleLabel.text = title;
    self.contentLabel.text = content;
    
    [self setNeedsLayout];
}


-(void)setSelected:(BOOL)selected animated:(BOOL)animated{
    
}

-(void)setHighlighted:(BOOL)highlighted animated:(BOOL)animated{
    
}

@end
